package com.zhang.controller;


import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {


    //获取认证通过对象
    @RequestMapping("/getAuthentication")
    public Authentication getAuthentication(){

        //当前认证通过的用户身份
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();


        return authentication;
    }



    //不用认证
    @RequestMapping("/index")
    public String index(){
        return "index";
    }

    //需要认证
    @RequestMapping("/demo1")
    public String demo1(){
        return "demo1";
    }

    @RequestMapping("/demo2")
    public String demo2(){
        return "demo2";
    }

    //需要认证+授权aaa
    @RequestMapping("/demo3")
    public String demo3(){
        return "demo3";
    }







    //登录成功
    @RequestMapping("/success")
    public String success(){
        return "success";
    }

    //登录失败
    @RequestMapping("/error")
    public String error(){
        return "error";
    }

}



